package com.kmwiki.Utility;

import java.io.*;
import java.util.Scanner;

public class myFile {

	
	public String read(String fFileName, String fEncoding)
	{
		String result;
		StringBuilder text = new StringBuilder();
	    String NL = System.getProperty("line.separator");
	    Scanner scanner = null;
	    try {
	     if (fEncoding.equals(""))
	         scanner = new Scanner(new FileInputStream(fFileName));
	     else
	         scanner = new Scanner(new FileInputStream(fFileName), fEncoding);
	      while (scanner.hasNextLine()){
	        text.append(scanner.nextLine() + NL);
	      }
	    }
	     catch (IOException ex){
	    	 //myLog.info("exception:"+ex.toString());
	    }
	    finally{
	      scanner.close();
	    }
	    result = text.toString();		
		return result;
	}
	
//	public void write(String fFileName, String fEncoding, String strContent) throws IOException  {
//	    //log("Writing to file named " + fFileName + ". Encoding: " + fEncoding);
//	    Writer out = new OutputStreamWriter(new FileOutputStream(fFileName), fEncoding);
//	    try {
//	      out.write(strContent);
//	    }
//	    finally {
//	      out.close();
//	    }		
//	}	
	
}
